/*
 ------------------------------------------------------------------------------
	winmad++ -	a test program for using SDL and mad library on Windows
				with object oriented UI style
				with low level mad (seek)

	Copyright (C) 2011 Pierre Veber
	
	This program is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation; either version 3 of the License, or
	(at your option) any later version.
	
	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.
	
	You should have received a copy of the GNU General Public License
	along with this program; if not, write to the Free Software Foundation,
	Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
------------------------------------------------------------------------------
*/

#pragma once

class CStyle;

/*
 ===========================================================================
	CSDLBase
 ===========================================================================
*/
class CSDLBase 
{
public:

	CSDLBase(char*, CSDLBase*, char*);
	virtual ~CSDLBase();

	char* name() { return this->lpszName; }

	virtual void draw();
	virtual void layout();

	virtual void onMouseOver();
	virtual void onMouseOut();
	virtual void onLeftClick();
	virtual void onRightClick();

protected:

	void addChild(CSDLBase*);
	SDL_Surface* surface() { return this->pSurface; }
	SDL_Surface* parentSurface() { return this->pParent->surface(); }
	CSDLBase* parent() { return this->pParent; }
	void mouseMove(int x, int y);
	void mouseClick(int button);

	int x, y, w, h;
	int nChild;
	SDL_Surface* pSurface;
	CStyle* pStyle;

private:
	
	char* lpszName;
	CSDLBase* pParent;
	CSDLBase** pChildList;
};

extern CSDLBase* pUnderMouse;

/*
 ===========================================================================
	CSDLText
 ===========================================================================
*/
class CSDLText : public CSDLBase
{
public:
	CSDLText(char* pszName, CSDLBase* pParent, char* pszStyle);
	~CSDLText();

	void setText(char* szUTF8);
	void draw();

private:
	char* szu8Text;
};

/*
 ===========================================================================
	CSDLApp
 ===========================================================================
*/
class CSDLApp : public CSDLBase
{
public:
	 CSDLApp(char* lpszAppName, char* lpszStyle);
	~CSDLApp();

	int run(char* pCmd);
	void draw();
};
